/// funckje bedace przedmiotem optymalizacji

/* Rosenbrock's valley f(x1,x2)
    x   argument
    g   (out) gradient
*/
double fRosenbrock(double*x, int n){
    return 100*(
                (x[1]-(x[0]*x[0]))*(x[1]-(x[0]*x[0]))
            )
            + (1-x[0])*(1-x[0]);
}

double n1QuadraticFunction(double*x, int n){
    double r = 0.0;
    int i;
    for (i=2; i<n; ++i){
        r += 100*(x[i]*x[i] + x[i-1]*x[i-1]) + x[i-2]*x[i-2];
    }
    return r;
}

double n12ArrowheadFunction(double*x, int n){
    double r = 0.0;
    int i;
    for (i=0; i<n-1; ++i){
        r += (x[i]*x[i] + x[n-1]*x[n-1])*(x[i]*x[i] + x[n-1]*x[n-1])   -4*x[i] + 3;
    }
    return r;
}

double n17QuarticFunction(double*x, int n){
    double r = 0.0;
    int i;
    for (i=0; i<n; ++i){
        r += i*x[i]*x[i];
    }
    return r*r;
}
